#pragma once
#include <vector>
#include "logger/logger.hpp"
#include "rga/rga.h"
#include "rga/im2d.h"
#include "rga/im2d.hpp"
#include "rga/im2d_type.h"

typedef enum {
    MODE_NONE,
    MODE_QUERYSTRING,  // 查询字符串
    MODE_COPY,         // 拷贝
    MODE_RESIZE,       // 重设大小
    MODE_CROP,         // 裁剪
    MODE_ROTATE,       // 旋转
    MODE_FLIP,         // 翻转
    MODE_TRANSLATE,    // 转码
    MODE_BLEND,        // 混合
    MODE_CVTCOLOR,     // CVT颜色
    MODE_FILL,         // 填充
    MODE_WHILE,
    MODE_MAX
} rga_mode_t;

typedef struct {
    int width;
    int height;
    RgaSURF_FORMAT format;
} rga_cfg_t;

class SmartRga {
public:
    SmartRga() {}
    // SmartRga(int src_width, int src_height, RgaSURF_FORMAT src_format, int dst_width, int dst_height, RgaSURF_FORMAT dst_format) {
    //     // rga_init(src_width, src_height, src_format, dst_width, dst_height, dst_format);
    // }
    ~SmartRga() {}
    // int init(int src_width, int src_height, RgaSURF_FORMAT src_format, int dst_width, int dst_height, RgaSURF_FORMAT dst_format) {
    //     return rga_init(src_width, src_height, src_format, dst_width, dst_height, dst_format);
    // }
    // int proc(rga_mode_t mode, std::vector<uint8_t>* src_buf, std::vector<uint8_t>* dst_buf) {
    //     return rga_proc(mode, *src_buf, *dst_buf);
    // }

private:
    // int rga_resize(std::vector<uint8_t>& src_buf, rga_cfg_t* src_cfg, std::vector<uint8_t>& dst_buf, rga_cfg_t* dst_cfg);
    // int rga_deinit();
    // int rga_proc(rga_mode_t mode, std::vector<uint8_t>& src_buf, std::vector<uint8_t>& dst_buf);

    int rga_query_string();
    int rga_copy();
    int rga_resize(std::vector<uint8_t>& src_buf, rga_cfg_t* src_cfg, std::vector<uint8_t>& dst_buf, rga_cfg_t* dst_cfg);  // 图像缩放
    int rga_crop();
    int rga_rotate();
    int rga_flip();
    int rga_translate();
    int rga_blend();
    int rga_cvtcolor();  // 图像格式转换
    int rga_fill();
    int rga_while();

private:
    // rga_cfg_t src_cfg;
    // rga_cfg_t dst_cfg;

    im_rect m_src_rect;
    im_rect m_dst_rect;
    rga_buffer_t m_src;
    rga_buffer_t m_dst;
    rga_buffer_handle_t m_src_handle;
    rga_buffer_handle_t m_dst_handle;
};